package test06;

import java.util.LinkedList;

public class Test06 {
    public static void main(String[] args) {
        System.out.println("===========第六题======================");
        test06();
    }

    public  static  void  test06(){

        Goods goods1 = new Goods("0001", "菠萝", 20.2);
        Goods goods2 = new Goods("0002", "香蕉", 35.6);
        Goods goods3 = new Goods("0003", "橘子", 45.2);
        Goods goods4 = new Goods("0004", "梨", 39.9);

         //添加商品的内容
        System.out.println("=====添加商品的内容========");
        LinkedList<Goods> list = new LinkedList<Goods>();
        list.add(goods1);
        list.add(goods2);
        list.add(goods3);
        list.add(goods4);

        //查看商品的数量
        System.out.println("=============查看商品的数量=================");
        System.out.println("商品数量：" + list.size());

        //遍历所有商品信息
        System.out.println("=============遍历所有商品信息=================");
        for (Goods goods : list) {
            System.out.println("商品编号：" + goods.getgNum() + "，商品名称：" +
                    goods.getgName() + "，商品价格：" + goods.getgPrice());
        }

        //删除商品元素
        System.out.println("===================删除商品元素==========================");
        System.out.println("删除橘子后");
        list.remove(3);


        //判断集合中是否包含指定商品
        System.out.println("=================判断集合中是否包含指定商品==============================");
        for (Goods goods : list) {
            System.out.println("商品编号：" + goods.getgNum() + "，" +
                    "商品名称：" + goods.getgName() + "，商品价格：" + goods.getgPrice());
        }
        System.out.println("集合中包含梨吗：" + list.contains(goods4));

    }
    }


